package com.tarena.lbs.basic.web.rpc;

import com.tarena.lbs.basic.api.AdminApi;
import com.tarena.lbs.basic.web.service.AdminService;
import com.tarena.lbs.pojo.basic.bo.AdminBO;
import com.tarena.lbs.pojo.basic.dto.AdminDTO;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

@Component
@Slf4j
public class AdminApiImpl implements AdminApi {
    @Autowired
    private AdminService adminService;
    @Override
    public AdminDTO getAdminDetail(Integer adminId) {
        try {
            AdminBO adminBO = adminService.adminDetail(adminId);
            if (adminBO!=null){
                adminBO.setAccountPassword(null);
                AdminDTO dto=new AdminDTO();
                BeanUtils.copyProperties(adminBO,dto);
                return dto;
            }
        }catch (Exception e){
            log.error("远程调用 使用adminid:{},查询失败",adminId,e);
        }
        return null;
    }
}
